/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Clases;

import java.util.Hashtable;
import java.util.LinkedList;

/**
 *
 * @author CESAR
 */
public class ListaCategoria {
    private LinkedList <Categoria> listaCat;
    private Hashtable<Integer,Categoria> hashCat;
    int ultimoId;

    public ListaCategoria() {
        
        listaCat= new LinkedList<Categoria>();
        hashCat=new Hashtable<Integer, Categoria>();
    
    }
    public void agregar(Categoria cat)
    {
        listaCat.add(cat);
        hashCat.put(cat.getId(), cat);
        ultimoId = cat.getId();
    }
    
    public Categoria buscar(int e)
    {
        return hashCat.get(e);        
    }
    
      public LinkedList <Categoria> getListaCategoria()
    {
        return listaCat;           
    }
      public int getUltimoId()
      {
          return ultimoId;
      }
    public boolean borrar(Categoria cat)
    {
         boolean b;
        b = listaCat.remove(cat);
        if (!b)return b;
        Categoria r = hashCat.remove(cat.getId());
        if(r == null ) return false;
        return b;
    }
}
